package com.bjpowernode.queue;

import java.util.Scanner;

/**
 * @ClassName Test2
 * @Description TODO
 * @date 2021/9/16 16:32
 * @Author ZY
 */
public class Test2 {
    public static void main(String[] args) {
        LoopQueue loopQueue = new LoopQueue(7);
        Scanner s = new Scanner(System.in);
        boolean loop = true;
        while (loop){
            System.out.println("1--->添加元素 | 2--->取出元素 | 3--->展示队列状态 | 0--->退出系统");
            char flag = s.next().charAt(0);
            switch (flag){
                case '1':
                    System.out.print("请输入数字:");
                    int i = s.nextInt();
                    loopQueue.add(i);
                    break;
                case '2':
                    try {
                        System.out.println(loopQueue.get());
                    }catch (RuntimeException re){
                        System.out.println(re.getMessage());
                    }
                    break;
                case '3':
                    System.out.println(loopQueue);
                    break;
                case '0':
                    loop = false;
                    break;
            }
            System.out.println();
        }
    }
}
